//=============lay vi tri phan tu=====================
//=----------------------
function textNULL(obj,canhbao)
{
	if(obj.value=="")
	{	alert(canhbao);
		this.focus();
	  	return true;
	}
	return false;	
}
//----------------------
function getRealLeft(el)
{
	xPos = document.getElementById(el).offsetLeft;
	tempEl = document.getElementById(el).offsetParent;
	while (tempEl != null) 
	{
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}

function getRealTop(el)
{
	yPos = document.getElementById(el).offsetTop;
	tempEl = document.getElementById(el).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	return yPos;
}

function dispTruePos(isID)
{
	trueX = getRealLeft(isID);
	trueY = getRealTop(isID);
	alert('True Xpos is: '+trueX+'\nTrue Ypos is: '+trueY)
}
//======================================================
function hienThiObject(id)
{
	document.getElementById(id).style.display="block";	
}
function anObject(id)
{
	document.getElementById(id).style.display="none";	
}
//-------------------------
function themText(objectcha,txtcon)
{
	var con=document.createTextNode(txtcon);
	objectcha.appendChild(con);
}
//----------------------
function xoaNode(objectcha,objectcon)
{
	objectcha.removeChild(objectcon);
}
//--------------------------------
function chonlichthoigian(doituonghienthi,idchualich)
{
	var congay=document.getElementById("congay");
	if(congay.value=="1")
	{
		var ngayden=document.getElementById('lichngay').value+"-"+document.getElementById('lichthang').value+"-"+document.getElementById('lichnam').value;
		doituonghienthi.value=ngayden;
		var xoa=document.getElementById(idchualich);
		//alert(xoa.length);
		xoa.removeChild(xoa.firstChild);
		anObject(idchualich);
	}
}
//=====================================================================================
//<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

function showdata(dd,hre)
{	//alert('document.themtour.nuoc.length');
   xmlhttp=GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   
   var url = hre;
   xmlhttp.onreadystatechange = function()
   {
	   if (xmlhttp.readyState == 4)
	   {//alert(xmlhttp.responseText);
	   		//var objtext=document.getElementById(thisid);
			var objdd=document.getElementById(dd);
			
		  document.getElementById(dd).innerHTML = xmlhttp.responseText;
		  objdd.style.display="block";
		  objdd.style.position="absolute";
		  objdd.style.left=0;
		  objdd.style.top=20;
		  objdd.style.zIndex="50";
	   }
	};
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);//alert(xmlhttp.responseText);
}
function showdataday(dd,hre)
{	//alert('document.themtour.nuoc.length');
   xmlhttp=GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   
   var url = hre;
   xmlhttp.onreadystatechange = function()
   {
	   if (xmlhttp.readyState == 4)
	   { //alert(xmlhttp.responseText);
	   		//var objtext=document.getElementById(thisid);
			var objdd=document.getElementById(dd);
			
		  document.getElementById(dd).innerHTML = xmlhttp.responseText;
		  objdd.style.display="block";
	   }
	};
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);//alert(xmlhttp.responseText);
}
//===============================================
function submitadmin(id,hre)
{	xmlhttp=GetXmlHttpObject();
   	if (xmlhttp == null)
   	{
      	alert ("Browser does not support HTTP Request");
      	return;
   	}
   	var url = hre;
   	xmlhttp.onreadystatechange = function()
   	{
	   	if (xmlhttp.readyState == 4)
	   	{ //alert(xmlhttp.responseText);
	   		//var objtext=document.getElementById(thisid);
			if(xmlhttp.responseText=="dung")
			{	document.form1.xacnhan.value="1";
				alert(xmlhttp.responseText);
			}
			else
			{
				var objdd=document.getElementById(id);
				document.getElementById(id).innerHTML = xmlhttp.responseText;
		  		objdd.style.display="block";
				alert(document.form1.xacnhan.value);
			}
	   }
	};
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);//alert(xmlhttp.responseText);
   if(document.form1.xacnhan.value=="1")
   		return true;
	else
   		return false;
	return false;
}
//=====================================
function showthongbao(hre)
{	//alert('document.themtour.nuoc.length');
   xmlhttp=GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   
   var url = hre;
   xmlhttp.onreadystatechange = function()
   {
	   if (xmlhttp.readyState == 4)
	   {	//alert(xmlhttp.responseText);
		  		
			
		  //document.getElementById(dd).style.display="block";
	   }
	};
   xmlhttp.open("GET", url, true);
   xmlhttp.send(null);//alert(xmlhttp.responseText);
}

//==========================function upload file=======================
function uploadfile(dd,hre)
{	//alert('document.themtour.nuoc.length');
   xmlhttp=GetXmlHttpObject();
   if (xmlhttp == null)
   {
      alert ("Browser does not support HTTP Request");
      return;
   }
   
   var url = hre;
   xmlhttp.onreadystatechange = function()
   {
	   if (xmlhttp.readyState == 4)
	   {	//alert(xmlhttp.responseText);
		  document.getElementById(dd).innerHTML = xmlhttp.responseText;
		  document.getElementById(dd).style.display="block";
	   }
	};
   xmlhttp.open("POST", url, false);
   xmlhttp.send(null);//alert(xmlhttp.responseText);
}

//====================================
function GetXmlHttpObject()
{
   if (window.XMLHttpRequest)
   {
      return new XMLHttpRequest();
   }
   if (window.ActiveXObject)
   {
      return new ActiveXObject("Microsoft.XMLHTTP");
   }
   return null;
}
function unshowajax()
{
	document.getElementById("hienthi").innerHTML="";
}
function clearList(id)
{
	var l=document.getElementById(id).parentNode;
	l.removeChild(l.childNodes[0]);
	l.style.display="none";
}
function chont(id,idlist,idparent)
{	var objtext=document.getElementById(id);
	if(objtext.value!="")
	{	var danhsach=document.getElementById(idlist);
		if(danhsach!=null)
			danhsach.focus();
		else
			document.getElementById(idparent).style.display="none";
	}
}